<?php
/**
 * Created by PhpStorm.
 * User: simon
 * Date: 2017/10/20
 * Time: 21:32
 */

require('../Util/Hashids.class.php');
require('../functions/functions.php');

$hashids = new Hashids();
dump($hashids->encode(1));  //jR

$hashids = new Hashids();
$id = $hashids->encode(1, 2, 3); // o2fXhV
$numbers = $hashids->decode($id); // [1, 2, 3]
dump($numbers);

$hashids = new Hashids();
$hashids->encode(1, 2, 3); // o2fXhV
$hashids->encode([1, 2, 3]); // o2fXhV
$hashids->encode('1', '2', '3'); // o2fXhV
$hashids->encode(['1', '2', '3']); // o2fXhV

//Pass a project name to make your ids unique:
$hashids = new Hashids('My Project');
dump($hashids->encode(1, 2, 3)); // Z4UrtW
dump($hashids->decode('Z4UrtW'));  // [1, 2, 3]

$hashids = new Hashids('My Other Project');
$hashids->encode(1, 2, 3); // gPUasb

//Use padding to make your ids longer:
$hashids = new Hashids(); // no padding
$hashids->encode(1); // jR

$hashids = new Hashids('', 10); // pad to length 10
dump($hashids->encode(1)); // VolejRejNm

//Pass a custom alphabet:
$hashids = new Hashids('', 0, 'abcdefghijklmnopqrstuvwxyz'); // all lowercase
$hashids->encode(1, 2, 3); // mdfphx

//Encode hex instead of numbers:
$hashids = new Hashids();
$id = $hashids->encode_hex('507f1f77bcf86cd799439011'); // y42LW46J9luq3Xq9XMly
dump($id);
dump($hex = $hashids->decode_hex($id)); // 507f1f77bcf86cd799439011

//When decoding, output is always an array of numbers (even if you encode only one number):
$hashids = new Hashids();
$id = $hashids->encode(1);
$hashids->decode($id); // [1]

//Encoding negative numbers is not supported.
//If you pass bogus input to encode(), an empty string will be returned:
$hashids = new Hashids();
$id = $hashids->encode('123a');
$id === ''; // true

$hashids = new Hashids();
$id = $hashids->encode('1');
dump($id);







